package com.ssy.lingxi.order.entity;

import com.fasterxml.jackson.annotation.JsonBackReference;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Objects;

/**
 * 平台后台 - 采购流程适用的会员
 * @author 万宁
 * @version 2.0.0
 * @date 2021-07-26
 */
@Entity
@Table(schema = "public", name = "ord_platform_purchase_process_member", indexes = {@Index(name = "ord_platform_purchase_process_member_process_id_idx", columnList = "platform_purchase_process_id"), @Index(name = "ord_platform_purchase_process_member_member_id_idx", columnList = "memberId"), @Index(name = "ord_platform_purchase_process_member_role_id_idx", columnList = "roleId")})
public class PlatformPurchaseProcessMemberDO implements Serializable {
    private static final long serialVersionUID = -8435291217220171868L;

    /**
     * 主键Id
     */
    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "ord_platform_purchase_process_member_seq")
    @SequenceGenerator(sequenceName = "ord_platform_purchase_process_member_seq", name = "ord_platform_purchase_process_member_seq", allocationSize = 1)
    private Long id;

    /**
     * 多对一双向关联基础采购流程
     */
    @JsonBackReference
    @ManyToOne(cascade = CascadeType.DETACH, fetch = FetchType.LAZY)
    @JoinColumn(name = "platform_purchase_process_id")
    private PlatformPurchaseProcessDO process;

    /**
     * 适用的会员Id
     */
    @Column
    private Long memberId;

    /**
     * 适用的会员角色Id
     */
    @Column
    private Long roleId;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public PlatformPurchaseProcessDO getProcess() {
        return process;
    }

    public void setProcess(PlatformPurchaseProcessDO process) {
        this.process = process;
    }

    public Long getMemberId() {
        return memberId;
    }

    public void setMemberId(Long memberId) {
        this.memberId = memberId;
    }

    public Long getRoleId() {
        return roleId;
    }

    public void setRoleId(Long roleId) {
        this.roleId = roleId;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }

        if (o == null || getClass() != o.getClass()) {
            return false;
        }

        PlatformPurchaseProcessMemberDO that = (PlatformPurchaseProcessMemberDO) o;
        return id.equals(that.id);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id);
    }
}
